package Ep01_Array.Feb27th_0026;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/2/28 14:00
 * 说明： 删除有序数组中的重复项。双指针 0026
 */

public class Mine {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 1, 2};
        Mine m = new Mine();
        System.out.println(m.removeDuplicates(nums));
    }

    public int removeDuplicates(int[] nums){
        int len = 1;
        int pointer = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i]>nums[pointer]){
                nums[++pointer] = nums[i];
                len++;
            }
        }
        return len;
    }


}
